package com.loyal.loyalerp.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import com.loyal.loyalerp.humenresource.role.model.GyRole;
import com.loyal.loyalerp.model.GyRolePermission;
@Mapper
public interface GyRolePermissionMapper {

	/**
	 * 
	 * @param permissionId
	 * @author wang zhenshan
	 */
	//根据permissionId删除gy_role_permission表中的相关数据
	@Delete("delete from gy_role_permission where permissionid=#{permissionId}")
	int deleteByPermissionId(Integer permissionId);
	
	@Select("select * from gy_role")
	List<GyRole> listRole();

	 int deleteByPrimaryKey(Integer id);


	    int insert(GyRolePermission record);

	    int insertSelective(GyRolePermission record);

	    GyRolePermission selectByPrimaryKey(Integer id);

	    int updateByPrimaryKeySelective(GyRolePermission record);

	    int updateByPrimaryKey(GyRolePermission record);
	    
	    //[1]查询显示所有的用户role
	    public List<GyRolePermission> queryByRoles() throws Exception;
	    
	    //[2]根据用户的roleid显示用户的权限
	    public List<GyRolePermission> getRoleIdToQuery(Integer roleid) throws Exception;
	    
	    //[3]left：根据用户的roleid查询对应权限的id
	    public List<GyRolePermission> queryByRoleIdGetPermissionId(Integer roleid) throws Exception;
	    
	    //[4]<!--根据权限和角色的id删除指定记录 ，用实体类分装  -->deleteByRoleIdAanPermissionId
	    public void deleteByRoleIdAanPermissionId(GyRolePermission gyRolePermission) throws Exception;
	    
	  //[5]页面左边：根据用户的permissionid显示用户的角色
	    public List<GyRolePermission> getpermissionIdToQuery(Integer permissionid) throws Exception;
	    
	  // 页面 righ:根据permissionId查询发挥对应的几条roleId  
	    public List<GyRolePermission> queryPermissionIdByGetRoleId(Integer permissionid) throws Exception;
    
    @Delete("delete from gy_role_permission where RoleId=#{id}")
	void deleteByRoleId(Integer id);
}